int cmp(int* x, int* y)
{
    return *y - *x;
}

int arrayPairSum(int* nums, int numsSize) {
    qsort(nums, numsSize, sizeof(int), cmp);
    int sum = 0, n = numsSize / 2, m = numsSize - 1;
    while (n)
    {
        sum += nums[m] > nums[m - 1] ? nums[m - 1] : nums[m];
        m = m - 2;
        n--;
    }
    for (int i = 0; i < numsSize; i++)
    {
        printf("%d  ", nums[i]);
    }
    return sum;
}